home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5986 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.th-darmstadt.de!news!enno
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q. only for ostrstream experts!!!
  5. Date: 07 Feb 1996 19:50:43 GMT
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Distribution: world
  8. Message-ID: <ENNO.96Feb7205043@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <4fab9d$1rp@fsuj01.rz.uni-jena.de>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: mkt@isun04.inf.uni-jena.de's message of 7 Feb 1996 14:00:13 GMT
  12.  
  13. In article <4fab9d$1rp@fsuj01.rz.uni-jena.de> mkt@isun04.inf.uni-jena.de (Tilo Koerbs) writes:
  14.  
  15.    Consider:
  16.        ostrstream buf();  // dynamic buffer
  17.        buf << "something" << ends;
  18.        char *p = buf.str();  // freeze buffer and return a pointer to it
  19.  
  20.    Now: How do I delete the pointer p, using 'delete' or using 'delete[]'?
  21.  
  22.    Please: Post only an answer if you are really sure! And consider: Even different
  23.    books give different answers!
  24.  
  25.    So if you know a standard's paper or the description of the original
  26.    implementation or something else, please post!
  27.  
  28. None of the proposed solutions is a reasonable way to release the allocated
  29. memory. An ostrstream provides the member-function 'freeze' which should be
  30. used to mark the underlying buffer as 'destroyable'.
  31. Anyway according to the DWP the memory for this buffer is _usually_ allocated
  32. via 'new char[...]' in which case 'delete[]' would be the right choice.
  33.  
  34.         Enno
  35.